// 应用配置相关类型定义

export interface AppConfig {
  version: string;
  app_version: string;
  auto_save_config: boolean;
  log_level: 'trace' | 'debug' | 'info' | 'warn' | 'error';
  theme: ThemeConfig;
  terminal_defaults: TerminalDefaults;
  security: SecurityConfig;
  recent_connections: string[];
  window: WindowConfig;
}

export interface ThemeConfig {
  name: string;
  mode: string;
  primary_color: string;
  secondary_color: string;
  colors: {
    primary: string;
    secondary: string;
    background: string;
    surface: string;
    text: string;
  };
}

export interface TerminalDefaults {
  font_family: string;
  font_size: number;
  cursor_style: 'block' | 'underline' | 'bar';
  cursor_blink: boolean;
  scrollback: number;
  bell_sound: boolean;
}

export interface SecurityConfig {
  auto_lock_timeout: number; // 秒
  auto_lock: boolean;
  lock_timeout_minutes: number;
  remember_passwords: boolean;
  encrypt_config: boolean;
  encrypt_passwords: boolean;
  clear_clipboard: boolean;
}

export interface WindowConfig {
  width: number;
  height: number;
  default_width: number;
  default_height: number;
  remember_size: boolean;
  remember_position: boolean;
}

export interface ConnectionConfig {
  id: string;
  name: string;
  ssh_config: SshConfig;
  tunnels: TunnelConfig[];
  terminal_config: TerminalConfigOverride;
  tags: string[];
  notes?: string;
  created_at: string;
  last_used_at?: string;
  use_count: number;
}

export interface TerminalConfigOverride {
  size: TerminalSize | null;
  shell: string | null;
  env_vars: Record<string, string>;
  working_directory: string | null;
}

export interface TerminalSize {
  cols: number;
  rows: number;
}

export interface SshConfig {
  host: string;
  port: number;
  username: string;
  auth_method: AuthMethod;
  password?: string;
  private_key_path?: string;
  private_key_passphrase?: string;
  use_agent: boolean;
  connect_timeout: number;
  keepalive_interval: number;
  compression: boolean;
  proxy_jump?: string;
}

export interface AuthMethod {
  type: 'password' | 'public_key' | 'agent' | 'interactive';
  data?: Record<string, any>;
}

export interface TunnelConfig {
  id: string;
  name: string;
  tunnel_type: TunnelType;
  local_host: string;
  local_port: number;
  remote_host: string;
  remote_port: number;
  enabled: boolean;
}

export type TunnelType = 'local' | 'remote' | 'dynamic';